import json

def main(body: str) -> dict:
    data = json.loads(body)
    result_type = data.get("result_type")
    results = []

    if result_type == "nodes":
        nodes = data.get("nodes", [])
        results = [node.get("content") for node in nodes if "content" in node]

    elif result_type == "chains":
        chains = data.get("chains", [])
        for chain_obj in chains:
            chain = chain_obj.get("chain", [])
            # 拼接这个 chain 下的所有 content 字段（用空格或换行符分隔都可）
            contents = [item["content"] for item in chain if "content" in item]
            joined = " -> ".join(contents)  # 可改为"\n".join(contents)等样式
            results.append(joined)

    return {
        "result": results
    }

main